
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
集成日志显示、存档、作用域、debug多功能一体,开箱即用的日志模块。
没有日志等级概念,可以灵活的配置每个日志类型
支持日志作用域,默认全局匹配,通过环境变量logger限定作用域范围
可定制存储格式,默认使用text格式日志
日志定期存盘,默认间隔3s
日志拆分,文件按天保存到logger目录下
cluster多进程日志,建议通过agent运行
动态切换日志配置,如在生产环境下临时查看log
自定义cli显示内容格式及文件保存格式
显示格式化的彩色文本、图标日志
可扩展自定义日志类型
配置简单,易定制
轻量级、高性能,生产环境与测试环境代码分离,剔除所有与生产环境无关联的代码,使用最优惰性配置
const logger = require('loggercc');
if (process.env.NODE === 'production') {
logger.production()
}
logger.log('hellow log')
logger.success('hellow success')
logger.warn({ a: 1 })
logger.error(new Error(''))
logger.success('888')
npm install loggercc
开发环境下默认仅显示日志,不存盘。通过logger.development()配置覆盖默认行为
logger.development(options)
options
Object 自定义配置选项,可选
$type
Object 类型配置选项,$type对应类型名称
show
Boolean, Function 在cli中显示log,当值为函数时表示使用自定义显示格式
save
Boolean, Function 是否保存至文件,当值为函数时表示使用自定义存储格式,默认为false
filename
String 保存文件名
action
Function 覆盖默认logger的处理逻辑,或为自定义logger添加处理逻辑(!谨慎操作)
logger.development({
"log": {
"show": true,
"save": false,
"filename": "log.log"
},
"success": {
"show": true,
"save": false,
"filename": "success.log"
},
"warn": {
"show": true,
"save": false,
"filename": "warning.log"
},
"error": {
"show": true,
"save": false,
"filename": "error.log"
}
})
生产环境下默认不显示日志,也不存盘。通过logger.production()配置开启日志存盘功能。
logger.production(options)
options
Object 自定义配置选项,可选
$type
Object 类型配置选项,$type对应类型名称
save
Boolean, Function 是否保存至文件,当值为函数时表示使用自定义存储格式,默认为false
filename
String 保存文件名
action
Function 覆盖默认logger的处理逻辑,或为自定义logger添加处理逻辑(!谨慎操作)
logger.production({
"log": {
"save": false,
"filename": "log.log"
},
"success": {
"save": false,
"filename": "success.log"
},
"warn": {
"save": true,
"filename": "warning.log"
},
"error": {
"save": true,
"filename": "error.log"
},
})
在loggercc中可以很方便的定制日志显示格式和存储格式,在自定义配置函数中绑定了一些常用日志属性,帮助快速合成日志格式。
this.getDate()
Function 生成日志时间函数
this.parameter(argv)
Function argv参数处理
this.pid
String 进程id
this.hostname
String 主机名称
this.type
String 日志类型
logger.development({
"success": {
"save": true,
show(argv) {
// 显示格式
console.log(`\x1b[32m😊 ${this.type} [${this.getDate()}] \x1b[39m`, ...argv)
}
},
"warn": {
show(argv) {
console.log(`\x1b[32m🐷 ${this.type} [${this.getDate()}] \x1b[39m`, ...argv)
},
save(argv) {
// 保存为JSON格式
return JSON.stringify({
date: this.getDate(),
type: this.type,
pid: this.pid,
hostname: this.hostname,
argv
})
}
},
"error": {
save(argv) {
// 保存为TEXT格式
return `[${this.getDate()}] ${this.type} ${this.pid} ${this.hostname} ${argv}`
}
}
})
日志作用域的使用方法与debug模块类似,区别如下:
debug默认不显示log,loggercc默认显示log,通过logger.production()切换到生产环境后关闭日志。
debug使用“debug”作为环境变量名,loggercc使用“logger”作为环境变量名。
debug的环境变量值支持模糊匹配,loggercc不支持模糊匹配,但支持精确匹配多个作用域。
const app = require('loggercc')('app');
app.success('ok')
FAQs
简单、高性能的node.js日志显示、存档工具
The npm package loggercc receives a total of 0 weekly downloads. As such, loggercc popularity was classified as not popular.
We found that loggercc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.